package com.wude.guild.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wude.guild.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 描述：领取优惠券成功Dialog
 * 时间: 2017-09-04 11:59
 */
public class GetCouponDialog extends Dialog {
    @BindView(R.id.btn_close)
    RelativeLayout btnClose;
    @BindView(R.id.tv_1)
    TextView tv1;
    @BindView(R.id.btn_ok)
    TextView btnOk;
    @BindView(R.id.tv_content)
    TextView tv_content;

    private String title;
    private String content;
    private String buttonString;


    public GetCouponDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
    }

    public GetCouponDialog(@NonNull Context context, String title, String content, String buttonString) {
        super(context);

        this.title = title;
        this.content = content;
        this.buttonString = buttonString;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去标题栏

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.dialog_youhuiquan_seccess);
        ButterKnife.bind(this);

        Window window = this.getWindow();
        window.setBackgroundDrawableResource(R.color.transparency);
        window.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;


        tv1.setText(title);
        tv_content.setText(content);
        btnOk.setText(buttonString);
    }

    public TextView getButton() {
        return btnOk;
    }

    @OnClick({R.id.btn_close, R.id.btn_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_close:
                dismiss();
                break;
            case R.id.btn_ok:
                dismiss();
                break;
        }
    }
}

